import mysql.connector
class sql_action:
    def __init__(self):
        self._conn_dict = dict(host='192.168.1.6', user='root', password='Y1}E5<Zd4Jv%', database='md_test')

    def _sql_change(self,sql,params):
        conn = mysql.connector.connect(**self._conn_dict)
        cursor = conn.cursor()
        cursor.execute(sql, params)
        conn.commit()
        cursor.close()
        conn.close()


    def _sql_selectone(self,sql,*params):
        conn = mysql.connector.connect(**self._conn_dict)
        cursor = conn.cursor()
        cursor.execute(sql, params)
        values = cursor.fetchone()
        cursor.close()
        conn.close()
        return values

    def _sql_selectall(self,sql,*params):
        conn = mysql.connector.connect(**self._conn_dict)
        cursor = conn.cursor()
        cursor.execute(sql, params)
        data = cursor.fetchall()
        cursor.close()
        conn.close()
        return data